const express = require('express')
const app = express()
const bodyParser = require('body-parser'
)
//处理静态资源
app.use(express,static('public'))
//处理参数
app.use(bodyParser.json())
app.use(bodyPaser.urlencoded({extended:false}))

//s设置允许跨域访问服务器
app.all("*", function(req, res, next) {
	res.header('Access-Control-Allow-Origin', "*")
	res.header('Access-Control-Allow-Methods', "PUT, GET, POST, DELETE, OPTIONS")
	res.header('Access-Control-Allow-Headers', "X-Requested-With")
	res.header('Access-Control-Allow-Headers', "Content-Type")
})

app.get('/data', (req, res) => {
	res.send('Hello World')
})
app.listen(8080, () => {
	coslole.log('Server is runing...','http://localhost.127.0.0.1')
})